package com.sbpm.crmbpm.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.ui.*;
import com.sbpm.crmbpm.client.application.ApplicationContextLoader;
import com.sbpm.crmbpm.client.panels.tabs.MainTabsPanel;
import com.sbpm.crmbpm.client.panels.views.MainView;
import com.sbpm.crmbpm.client.util.SimpleAsyncCallback;
import com.sencha.gxt.widget.core.client.PlainTabPanel;
import com.sencha.gxt.widget.core.client.TabItemConfig;
import com.sencha.gxt.widget.core.client.TabPanel;
import com.sencha.gxt.widget.core.client.info.Info;


public class CrmBpm implements EntryPoint
{

    private MainTabsPanel mainTabsPanel;
    private MainView mainView;

    private Widget createApplication()
    {
//        mainTabsPanel = new MainTabsPanel();
//        return mainTabsPanel;


        mainView = new MainView();
        return mainView;

    }


    @Override
    public void onModuleLoad()
    {
        ApplicationContextLoader.load( new SimpleAsyncCallback()
        {
            @Override
            public void onSuccess( Object result )
            {
                RootPanel.get().add( createApplication() );
            }
        } );

    }

    /*private VerticalPanel vp;

    public Widget asWidget() {
        if (vp == null) {
            vp = new VerticalPanel();
            vp.setSpacing(10);

            String txt = "test dfg sdfg sdfg ";

            SelectionHandler<Widget> handler = new SelectionHandler<Widget>() {
                @Override
                public void onSelection(SelectionEvent<Widget> event) {
                    TabPanel panel = (TabPanel) event.getSource();
                    Widget w = event.getSelectedItem();
                    TabItemConfig config = panel.getConfig(w);
                    Info.display( "Message", "'" + config.getText() + "' Selected" );
                }
            };

            TabPanel folder = new TabPanel();
            folder.addSelectionHandler(handler);
            folder.setWidth(450);

            HTML shortText = new HTML(txt);
            shortText.addStyleName("pad-text");
            folder.add(shortText, "Short Text");

            HTML longText = new HTML(txt + "<br><br>" + txt);
            longText.addStyleName("pad-text");
            folder.add(longText, "Long Text");

            final PlainTabPanel panel = new PlainTabPanel();
            panel.setPixelSize(450, 250);
            panel.addSelectionHandler(handler);

            Label normal = new Label("Just a plain old tab");
            normal.addStyleName("pad-text");
            panel.add(normal, "Normal");

            Label iconTab = new Label("Just a plain old tab with an icon");
            iconTab.addStyleName("pad-text");

            TabItemConfig config = new TabItemConfig("Icon Tab");
//            config.setIcon(Resources.IMAGES.table());
            panel.add(iconTab, config);

            Label disabled = new Label("This tab should be disabled");
            disabled.addStyleName("pad-text");

            config = new TabItemConfig("Disabled");
            config.setEnabled(false);
            panel.add(disabled, config);

            vp.add(folder);
            vp.add(panel);
        }

        return vp;
    }

    public void onModuleLoad() {
        RootPanel.get().add(asWidget());
    }*/

}

